import request from '@/utils/request'
import type { Permission } from '@/types/api/permission'

// 获取权限列表
export function getPermissionList() {
  return request<Permission[]>({
    url: '/permission/list',
    method: 'get'
  })
}

// 获取权限树
export function getPermissionTree() {
  return request<Permission[]>({
    url: '/permission/tree',
    method: 'get'
  })
}

// 添加权限
export function addPermission(data: Partial<Permission>) {
  return request({
    url: '/permission',
    method: 'post',
    data
  })
}

// 更新权限
export function updatePermission(data: Partial<Permission>) {
  return request({
    url: `/permission/${data.id}`,
    method: 'put',
    data
  })
}

// 删除权限
export function deletePermission(id: number) {
  return request({
    url: `/permission/${id}`,
    method: 'delete'
  })
} 